
package sixth.group.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import sixth.group.domain.Orderinf;
import sixth.group.domain.Restaurant;
import sixth.group.service.WwzOrderinfService;
import sixth.group.utils.MessageAndData;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping({"/orderinf"})
public class WwzOrderinfController {
    @Autowired
    private WwzOrderinfService wwzOrderinfService;


    @RequestMapping({"/customercheckorderinf"})
    @ResponseBody
    public MessageAndData customercheckOrderinf(int cid) {
        List<Orderinf> orderinfs = wwzOrderinfService.CustomerCheckOrderinf(cid);
        MessageAndData orderlist = MessageAndData.success().add("orderlist", orderinfs);
        return orderlist;
    }

    @RequestMapping({"clist"})
    @ResponseBody
    public MessageAndData clist() {
        List<Orderinf> orderinfs = wwzOrderinfService.SelectAll();
        MessageAndData clist = MessageAndData.success().add("clist", orderinfs);
        return clist;
    }

    @RequestMapping({"rlist"})
    @ResponseBody
    public MessageAndData rlist() {
        List<Orderinf> orderinfs = wwzOrderinfService.SelectAll();
        MessageAndData rlist = MessageAndData.success().add("rlist", orderinfs);
        return rlist;
    }

    @RequestMapping({"/restaurantcheckorderinf"})
    @ResponseBody
    public MessageAndData restaurantcheckOrderinf(HttpSession httpSession) {
        Integer rid;
        Restaurant restaurant= (Restaurant) httpSession.getAttribute("RESTAURANT_SESSION");
        rid=restaurant.getRid();

        List<Orderinf> orderinfs = wwzOrderinfService.RestaurantCheckOrderinf(rid);
        MessageAndData orderlist = MessageAndData.success().add("orderlist", orderinfs);
        return orderlist;
    }


}
